<?php

namespace app\common\model;

use think\Model;

class Search extends Model
{
    //添加搜索
    public function  creatSearch($data){
        $validate = new \app\common\validate\Search();
        if (!$validate->scene('add')->check($data)){
            return $validate->getError();
        }
        $result = $this->allowField(true)->save($data);
        if ($result){
            return 1;
        }else{
            return '添加搜索失败';
        }

    }
    //删除搜索
    public function deleteSearch(){

    }
    //分类搜索
    public function listeSearch(){

    }
    //修改搜索
    public function updateSearch($id,$data){
        $validate = new \app\common\validate\Search();
        if (!$validate->scene('add')->check($data)){
            return $validate->getError();
        }
        $result = $this->where('id',$id)->update($data);
        if ($result){
            return 1;
        }else{
            return '修改失败';
        }
    }
}
